package com.rop.znyx.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rop.znyx.model.product.AttrGroup;
import com.rop.znyx.product.mapper.AttrGroupMapper;
import com.rop.znyx.product.service.AttrGroupService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rop.znyx.vo.product.AttrGroupQueryVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 属性分组 服务实现类
 * </p>
 *
 * @author rop
 * @since 2023-06-24
 */
@Service
public class AttrGroupServiceImpl extends ServiceImpl<AttrGroupMapper, AttrGroup> implements AttrGroupService {

    /**
     * 获取平台属性分组列表
     */
    @Override
    public IPage<AttrGroup> selectByPage(Page<AttrGroup> pageParam, AttrGroupQueryVo attrGroupQueryVo) {
        // 查询条件
        String name = attrGroupQueryVo.getName();

        LambdaQueryWrapper<AttrGroup> queryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.isNotBlank(name)) {
            queryWrapper.like(AttrGroup::getName, name);
        }

        return baseMapper.selectPage(pageParam, queryWrapper);
    }

    /**
     * 获取全部平台属性分组
     */
    @Override
    public List<AttrGroup> findAllList() {
        return baseMapper.selectList(null);
    }
}
